package com.sixbro.shiro.common.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

/**
 * <p>
 *
 * </p>
 *
 * @Author: Mr.Lu
 * @Since: 2020/6/19 13:34
 */
@Component
@ConfigurationProperties(prefix = FileUploadProperties.PREFIX)
public class FileUploadProperties {
    public static final String PREFIX = "app.file";


    private String path;
    private String url;
    private String accessUrl;

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;

        //set accessUrl
        if (StringUtils.isEmpty(url)) {
            this.accessUrl = null;;
        }
        this.accessUrl = url.substring(url.lastIndexOf("/")) + "/**";
        System.out.println("accessUrl="+accessUrl);
    }

    public String getAccessUrl() {
        return accessUrl;
    }
}
